<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:jsf="http://xmlns.jcp.org/jsf"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:p="http://primefaces.org/ui">


    <h:form>
        <p:commandLink styleClass="btn btn-default btn-primary" update=":panelContent">
            <i class="glyphicon glyphicon-search"/>
            REGGRESAR AL LISTADO
            <f:setPropertyActionListener
                target="#{navigationController.navigationContent}"
                value="./pages/operation/register_product/document_view.xhtml" />
        </p:commandLink>
    </h:form>
    <hr/>
    <div class="row">
        <div class="col-lg-3">
            <div class="input-group">
                <span class="input-group-addon">DOCUMENTO </span>
                <label class="form-control" jsf:value="#{documentController.inputDocument.typeDocument}" />
            </div>

        </div>
        <div class="col-lg-3">
            <div class="input-group">
                <span class="input-group-addon">Nº DOCUMEN</span>
                <label class="form-control" jsf:value="#{documentController.inputDocument.numberDocument}" />
            </div>
        </div>
        <div class="col-lg-3" align="right">
            <div class="input-group">
                <span class="input-group-addon">MONEDA </span>
                <label class="form-control" jsf:value="#{documentController.inputDocument.typeMoney}" />
            </div>
        </div>
        <div class="col-lg-3">
            <div class="input-group" >
                <span class="input-group-addon">IGV.</span>
                <label class="form-control" jsf:value="#{documentController.inputDocument.igv}" />
                <span class="input-group-addon">%</span>
            </div>
        </div>
    </div>
    <br/>
    <div class="row">

        <div class="col-lg-6">
            <div class="input-group">
                <span class="input-group-addon">PROVEEDOR.</span>
                <label class="form-control" jsf:value="#{documentController.inputDocument.providerId.name}" />
            </div>
        </div>
        <div class="col-lg-6">
            <div class="input-group">
                <span class="input-group-addon">FECHA </span>
                <label class="form-control" jsf:value="#{documentController.inputDocument.inputDate}" />
            </div>
        </div>
    </div>
    <br/>
    <div class="row">
        <div class="col-lg-6">
            <div class="input-group">
                <span class="input-group-addon">Tipo de Moneda.</span>
                <label class="form-control" jsf:value="#{documentController.inputDocument.typeMoney}" />
            </div>
        </div>
        <div class="col-lg-6">
            <div class="input-group">
                <span class="input-group-addon">Responsable de Ingreso.</span>
                <label class="form-control" jsf:value="#{documentController.inputDocument.employeeId.firstName} #{documentController.inputDocument.employeeId.lastName}" />
            </div>
        </div>
    </div>
    <hr/>

    <div align="center">
        <h3><h:outputText value="Detalle de la Compra"/></h3>
        <hr/>
    </div>

    <p:dataTable emptyMessage="No ha añadido ningún producto." id="tableForm"
                 value="#{documentController.inputDocument.detailInputDocumentList}" 
                 var="detail">

        <p:column headerText="Cantidad" width="10">
            #{detail.amount}
        </p:column>
        <p:column headerText="Nombre o Descripción">
            #{detail.productId.name}
        </p:column>
        <p:column headerText="Etiquitas">
            <div align="center" jsf:rendered="#{detail.productId.categoryId.name != null}">
                CATEGORIA[<strong>#{detail.productId.categoryId.name}</strong>] 
            </div>
            <div align="center" jsf:rendered="#{detail.productId.categoryId.name != null}">
                UNIDAD[<strong>#{detail.productId.unitTypeId.name}</strong>] 
            </div>
            <div align="center" jsf:rendered="#{detail.productId.categoryId.name != null}">
                MARCA[<strong>#{detail.productId.markId.name}</strong>] 
            </div>
        </p:column>
        <p:column headerText="P.U" width="90">
            #{detail.priceUnit}
        </p:column>
        <p:column headerText="Sub Total" width="90">
            #{detail.subTotal}
        </p:column>

        <p:columnGroup type="footer" >   
            <p:row>  
                <p:column colspan="4" footerText="SUB TOTAL" style="text-align:right"  />  
                <p:column footerText="#{documentController.inputDocument.subTotal}" style="text-align:center"  />
            </p:row>  
            <p:row>  
                <p:column colspan="4" footerText="IGV" style="text-align:right"  />  
                <p:column footerText="#{documentController.inputDocument.igv} %" style="text-align:center"  />
            </p:row> 
            <p:row>  
                <p:column colspan="4" footerText="TOTAL"  
                          style="text-align:right"  />  
                <p:column footerText="#{documentController.inputDocument.total}"  
                          style="text-align:center;"  />
            </p:row> 
        </p:columnGroup>  
    </p:dataTable>

    <hr/>
</ui:composition>
